package com.cddx.logistics.util.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result<T> {

    private int code;
    private String msg;
    private T data;

    public static <T> Result<T> ok(String msg) {
        return new Result<>(0, msg, null);
    }

    public static <T> Result<T> error(String msg) {
        return new Result<>(1, msg, null);
    }

    public static <T> Result<T> error(String msg, T data) {
        return new Result<>(1, msg, data);
    }
}
